﻿using EventBus.Abstractions;
using Location.API.Model;
using Location.API.Repositories;
using Location.API.ViewModel;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Location.API.Infrastructure.Services
{
    public class LocationsService : ILocationsService
    {
        private readonly ILocationsRepository _locationsRepository;
        private readonly IEventBus _eventBus;
        private readonly ILogger<LocationsService> _logger;

        public LocationsService(
            ILocationsRepository locationsRepository,
            IEventBus eventBus,
            ILogger<LocationsService> logger)
        {
            _locationsRepository = locationsRepository ?? throw new ArgumentNullException(nameof(locationsRepository));
            _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
        public async Task<Locations> GetLocationsAsync(string locationId)
        {
            return await _locationsRepository.GetLocationsAsync(locationId);
        }
        public async Task<IEnumerable<Locations>> GetLocationListAsync()
        {
            return await _locationsRepository.GetLocationListAsync();
        }
        public async Task AddLocationsAsync(Locations Location)
        {
            await _locationsRepository.AddLocationsAsync(Location);
        }
        public async Task UpdateLocationsAsync(Locations location)
        {
            await _locationsRepository.UpdateLocationsAsync(location);
        }
        public async Task<IEnumerable<UserLocation>> GetUserLocationByUserIdAsync(string userId)
        {
            return await _locationsRepository.GetUserLocationByUserIdAsync(userId);
        }
        public async Task<IEnumerable<UserLocationResponse>> GetUserLocationAsync(string userId)
        {
           return await _locationsRepository.GetUserLocationAsync(userId);
        }
        public async Task AddUserLocationAsync(string userId, Locations location)
        {
            await _locationsRepository.AddUserLocationAsync(userId, location);
        }
        public async Task UpdateUserLocationAsync(string userId,Locations location)
        {
            await _locationsRepository.UpdateUserLocationAsync(userId,location);
        }
        public async Task<ResidentialAreasLocation> GetResidentialAreasLocationByAreasIdAsync(string residentialAreasId)
        {
            return await _locationsRepository.GetResidentialAreasLocationByAreasIdAsync(residentialAreasId);
        }
        public async Task<Locations> GetResidentialAreasLocationAsync(string residentialAreasId)
        {
          return  await _locationsRepository.GetResidentialAreasLocationAsync(residentialAreasId);
        }
        public async Task AddResidentialAreasLocationAsync(string residentialAreasLocationId, Locations location)
        {
            await _locationsRepository.AddResidentialAreasLocationAsync(residentialAreasLocationId, location);
        }
        public async Task UpdateResidentialAreasLocationAsync(string residentialAreasLocationId, Locations location)
        {
            await _locationsRepository.UpdateResidentialAreasLocationAsync(residentialAreasLocationId, location);
        }
        public async Task<ExpressStoreLocation> GetExpressStoreLocationByStoreIdAsync(string expressStoreLocationId)
        {
           return await _locationsRepository.GetExpressStoreLocationByStoreIdAsync(expressStoreLocationId);
        }
        public async Task<Locations> GetExpressStoreLocationAsync(string expressStoreId)
        {
            return await _locationsRepository.GetExpressStoreLocationAsync(expressStoreId);
        }
        public async Task AddExpressStoreLocationAsync(string expressStoreId, Locations location)
        {
            await _locationsRepository.AddExpressStoreLocationAsync(expressStoreId, location);
        }
        public async Task UpdateExpressStoreLocationAsync(string expressStoreId, Locations location)
        {
            await _locationsRepository.UpdateExpressStoreLocationAsync(expressStoreId, location);
        }
    }
}
